package com.luci.security.result;

import lombok.Data;

/**
 * <p>
 * 默认实现
 * 如果不符合自己的使用场景，请自定义一个实现 AuthResultAdapet的bean
 * </p>
 *
 * @author yuyanan
 * @since 2019/5/14
 */
@Data
public class DefaultAuthResult extends AuthResultAdapet {
    /**
     * 返回码
     */
    private int code;

    /**
     * 描述
     */
    private String msg;

    public DefaultAuthResult() {
        super(null);
    }

    public DefaultAuthResult(int code, String msg) {
        super(null);
        this.code = code;
        this.msg = msg;
    }
    @Override
    public AuthResultAdapet loginSuccess() {
        return Contant.loginSuccess;
    }

    @Override
    public AuthResultAdapet loginFail() {
        return Contant.loginFail;
    }

    @Override
    public AuthResultAdapet noToken() {
        return Contant.noToken;
    }

    @Override
    public AuthResultAdapet acessDenied() {
        return Contant.acessDenied;
    }

    public static class Contant {
        public static final DefaultAuthResult loginSuccess = new DefaultAuthResult(0, "登陆成功");
        public static final DefaultAuthResult loginFail = new DefaultAuthResult(103, "登陆失败");
        public static final DefaultAuthResult noToken = new DefaultAuthResult(401, "请登陆");
        public static final DefaultAuthResult acessDenied = new DefaultAuthResult(403, "凭证无效");
    }
}
